package cn.zxf.note.user.platform;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import jakarta.transaction.Transactional;

/**
 * Created by zengxf on 2020/3/25.
 */
@Component
public class UserPlatformSupport {

    @Autowired
    private UserPlatformRepository repos;

    public UserPlatform findOne(String platform, String openId) {
        return repos.findByPlatformAndOpenId(platform, openId);
    }

    @Transactional
    public void save(String platform, String openId, Integer userId) {
        UserPlatform up = new UserPlatform()
                .setPlatform(platform)
                .setOpenId(openId)
                .setUserId(userId);
        repos.save(up);
    }

}
